package common

import "strconv"

type Convert struct {}

// bool 转化为字符串
func (convert *Convert) BoolToString(boolValue bool) string {
	if (boolValue == true) {
		return "true";
	}else {
		return "false";
	}
}

//bool 转化为 int
func (convert *Convert) BoolToInt(boolValue bool) int {
	if(boolValue == true) {
		return 1;
	}else {
		return 0;
	}
}

//int 转化为 bool
func (convert *Convert) IntToBool(number int) bool {
	if(number == 0) {
		return false;
	}else {
		return true;
	}
}

//int 转化为字符串
//base 范围 2-32 进制
func (convert *Convert) IntToString(number int64, base int) string {
	return strconv.FormatInt(number, base);
}

//string to int(10进制)
func (convert *Convert) StringToInt(str string) int {
	intValue, _ := strconv.Atoi(str);
	return intValue
}

//int 转化为10进制字符串 IntToString(number, 10)
func (convert *Convert) IntToTenString(number int) string {
	return strconv.Itoa(number)
}

// float 转化为字符串
func (convert *Convert) FloatToString(f float64, fmt byte, prec, bitSize int) string {
	return strconv.FormatFloat(f, fmt, prec, bitSize);
}